using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentAttendanceTableManager class is responsible for managing BO.StudentAttendanceTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentAttendanceTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentAttendanceTable objects in the database.
        /// </summary>
        /// <returns>A list with all StudentAttendanceTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentAttendanceTableList GetList()
        {
            return StudentAttendanceTableDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentAttendanceTable from the database without its data.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceTable in the database.</param>
        /// <returns>A StudentAttendanceTable object when the AttKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceTable GetItemBySectionNo(int EduPeriodKey, int ClassRoomKey, Int16 DayCode, DateTime AttDate, Int16 SectionNo)
        {
            return StudentAttendanceTableDB.GetItemBySectionNo(EduPeriodKey, ClassRoomKey, DayCode, AttDate, SectionNo);
        }

        /// <summary>
        /// Gets a single StudentAttendanceTable from the database without its data.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceTable in the database.</param>
        /// <returns>A StudentAttendanceTable object when the AttKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceTable GetItemByAttDate(int EduPeriodKey, int ClassRoomKey, Int16 DayCode, DateTime AttDate)
        {
            return StudentAttendanceTableDB.GetItemByAttDate(EduPeriodKey, ClassRoomKey, DayCode, AttDate);
        }

        /// <summary>
        /// Gets a single StudentAttendanceTable from the database without its data.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceTable in the database.</param>
        /// <returns>A StudentAttendanceTable object when the AttKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceTable GetItem(long attKey)
        {
            return GetItem(attKey, false);
        }

        /// <summary>
        /// Gets a single StudentAttendanceTable from the database.
        /// </summary>
        /// <param name="attKey">The AttKey of the StudentAttendanceTable in the database.</param>
        /// <param name="getStudentAttendanceTableRecords">Determines whether to load all associated StudentAttendanceTable records as well.</param>
        /// <returns>
        /// A StudentAttendanceTable object when the AttKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentAttendanceTable GetItem(long attKey, bool getStudentAttendanceTableRecords)
        {
            StudentAttendanceTable myStudentAttendanceTable = StudentAttendanceTableDB.GetItem(attKey);
            return myStudentAttendanceTable;
        }

        /// <summary>
        /// Saves a StudentAttendanceTable in the database.
        /// </summary>
        /// <param name="myStudentAttendanceTable">The StudentAttendanceTable instance to save.</param>
        /// <returns>The new AttKey if the StudentAttendanceTable is new in the database or the existing AttKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static long Save(StudentAttendanceTable myStudentAttendanceTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                long studentAttendanceTableAttKey = StudentAttendanceTableDB.Save(myStudentAttendanceTable);

                //  Assign the StudentAttendanceTable its new (or existing AttKey).
                myStudentAttendanceTable.AttKey = studentAttendanceTableAttKey;

                myTransactionScope.Complete();

                return studentAttendanceTableAttKey;
            }
        }

        /// <summary>
        /// Deletes a StudentAttendanceTable from the database.
        /// </summary>
        /// <param name="myStudentAttendanceTable">The StudentAttendanceTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentAttendanceTable myStudentAttendanceTable)
        {
            return StudentAttendanceTableDB.Delete(myStudentAttendanceTable.AttKey);
        }

        /// <summary>
        /// Deletes a StudentAttendanceTable from the database.
        /// </summary>
        /// <param name="myStudentAttendanceTable">The StudentAttendanceTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(Int64 AttKey)
        {
            return StudentAttendanceTableDB.Delete(AttKey);
        }

        #endregion

    }

}
